try-or, or-try, try-else or else-try?

utilities — cgrand, 8 January 2009 @ 18 h 26 min

I can’t decide which name is best for this macro:

(defmacro try-or
 "Evaluates exprs one at a time, from left to right. If a form returns a 
  value, this value is returned. If a form throws an exception, the next 
  form is evaluated. 
  If the last form throws an exception, the exception isn't caught." 
 ([] nil)
 ([form] form)
 ([form & forms]
   `(try 
      ~form
      (catch Exception e#
        (try-or ~@forms)))))
(c) 2024 Clojure and me | powered by WordPress with Barecity